home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12887 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  43 lines

  1. Path: jove.acs.unt.edu!rortega
  2. From: Reynaldo Ortega <rortega@jove.acs.unt.edu>
  3. Newsgroups: comp.lang.c
  4. Subject: Turbo C beginner: string question? Please help!
  5. Date: Wed, 3 Apr 1996 06:02:20 -0600
  6. Organization: University of North Texas
  7. Message-ID: <Pine.SOL.3.91.960403054553.29446A-100000@jove.acs.unt.edu>
  8. NNTP-Posting-Host: jove.acs.unt.edu
  9. Mime-Version: 1.0
  10. Content-Type: TEXT/PLAIN; charset=US-ASCII
  11.  
  12. /* A simple string example */
  13.  
  14. main()
  15. {
  16.   char str[80];
  17.  
  18.   printf("enter you name: ");
  19.  
  20.   gets(str);
  21.  
  22.   printf("hello %s", str);
  23. }
  24.  
  25. QUESTION:
  26.  let's say I entered the name TARANTINO, and I wanted to compare each 
  27. single character in the string to display a count of occurences of 
  28. each character. How would I code this? Here is an example to clarify
  29. what I am asking:
  30. ************************************************************
  31. enter your name: Tarantino
  32. hello Tarantino
  33. Tarantino has: 2 - t
  34. Tarantino has: 2 - a
  35. Tarantino has: 1 - r
  36. Tarantino has: 2 - n
  37. Tarantino has: 1 - i
  38. Tarantino has: 1 - o
  39. **************************************************************
  40. Thanx for any help,
  41.  
  42. Ray         e-mail: rortega@jove.acs.unt.edu
  43.